HAL TIM constants migration ¶
This section provides information about the HAL TIM constants migration.
HAL TIM output compare clear (OCREFCLR) source ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_CLEARINPUTSOURCE_OCREFCLR
.
.
.
#define TIM_CLEARINPUTSOURCE_ETR
#define TIM_CLEARINPUTSOURCE_NONE
|
typedef enum
{
HAL_TIM_OCREF_CLR_TIM1_ETR
HAL_TIM_OCREF_CLR_TIM1_COMP1_OUT
.
.
.
} hal_tim_ocref_clr_src_t;
Important
In HAL2, the OCREFCLR source is transitioned to an enumeration type,
|
HAL TIM DMA base address ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_DMABASE_CR1
#define TIM_DMABASE_CR2
#define TIM_DMABASE_xx
.
.
.
|
typedef enum
{
HAL_TIM_DMABURST_BASE_ADDR_CR1
HAL_TIM_DMABURST_BASE_ADDR_CR2
HAL_TIM_DMABURST_BASE_ADDR_xx
.
.
.
} hal_tim_dmaburst_base_addr_reg_t;
|
HAL TIM slave mode ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_SLAVEMODE_DISABLE
#define TIM_SLAVEMODE_RESET
#define TIM_SLAVEMODE_GATED
#define TIM_SLAVEMODE_TRIGGER
#define TIM_SLAVEMODE_COMBINED_RESETTRIGGER
#define TIM_SLAVEMODE_COMBINED_GATEDRESET
#define TIM_SLAVEMODE_EXTERNAL1
|
typedef enum
{
HAL_TIM_SLAVE_DISABLED
HAL_TIM_SLAVE_RESET
HAL_TIM_SLAVE_GATED
HAL_TIM_SLAVE_TRIGGER
HAL_TIM_SLAVE_COMBINED_RESET_TRIGGER
HAL_TIM_SLAVE_COMBINED_GATED_RESET
} hal_tim_slave_mode_t;
Note
The
|
HAL TIM event source ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_EVENTSOURCE_UPDATE
#define TIM_EVENTSOURCE_CC1
.
.
.
|
typedef enum
{
HAL_TIM_SW_EVENT_UPD
HAL_TIM_SW_EVENT_CC1
.
.
.
} hal_tim_sw_event_id_t;
|
HAL TIM input channel polarity ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_INPUTCHANNELPOLARITY_RISING
#define TIM_INPUTCHANNELPOLARITY_FALLING
#define TIM_INPUTCHANNELPOLARITY_BOTHEDGE
|
typedef enum
{
HAL_TIM_IC_RISING
HAL_TIM_IC_FALLING
HAL_TIM_IC_RISING_FALLING
} hal_tim_ic_polarity_t;
|
HAL TIM external trigger polarity ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_ETRPOLARITY_INVERTED
#define TIM_ETRPOLARITY_NONINVERTED
|
typedef enum
{
HAL_TIM_EXT_TRIG_NONINVERTED
HAL_TIM_EXT_TRIG_INVERTED
} hal_tim_ext_trig_polarity_t;
|
HAL TIM external trigger prescaler ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_ETRPRESCALER_DIV1
#define TIM_ETRPRESCALER_DIV2
.
.
.
|
typedef enum
{
HAL_TIM_EXT_TRIG_DIV1
HAL_TIM_EXT_TRIG_DIV2
.
.
.
} hal_tim_ext_trig_prescaler_t;
|
HAL TIM counter mode ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_COUNTERMODE_UP
#define TIM_COUNTERMODE_DOWN
#define TIM_COUNTERMODE_CENTERALIGNED1
#define TIM_COUNTERMODE_CENTERALIGNED2
#define TIM_COUNTERMODE_CENTERALIGNED3
|
typedef enum
{
HAL_TIM_COUNTER_UP
HAL_TIM_COUNTER_DOWN
HAL_TIM_COUNTER_CENTER_DOWN
HAL_TIM_COUNTER_CENTER_UP
HAL_TIM_COUNTER_CENTER_UP_DOWN
} hal_tim_counter_mode_t;
|
HAL TIM clock division constants ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_CLOCKDIVISION_DIV1
#define TIM_CLOCKDIVISION_DIV2
#define TIM_CLOCKDIVISION_DIV4
|
typedef enum
{
HAL_TIM_DTS_DIV1
HAL_TIM_DTS_DIV2
HAL_TIM_DTS_DIV4
} hal_tim_dts_prescaler_t;
|
HAL TIM output channel polarity constants ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_OCPOLARITY_HIGH
#define TIM_OCPOLARITY_LOW
|
typedef enum
{
HAL_TIM_OC_HIGH
HAL_TIM_OC_LOW
} hal_tim_oc_polarity_t;
|
HAL TIM input capture selection constants ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_ICSELECTION_DIRECTTI
#define TIM_ICSELECTION_TRC
#define TIM_ICSELECTION_INDIRECTTI
|
typedef enum
{
HAL_TIM_IC_DIRECT
HAL_TIM_IC_TRC
HAL_TIM_IC_INDIRECT_RISING
HAL_TIM_IC_INDIRECT_FALLING
HAL_TIM_IC_INDIRECT_RISING_FALLING
} hal_tim_ic_capture_unit_src_t;
Note In HAL2, the configuration for selecting the TIM input capture source is enhanced, allowing developers to specify the desired edge-triggering behavior directly, specifically in indirect configuration. |
HAL TIM polarity ETR selection constants ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_ENCODERINDEX_POLARITY_INVERTED TIM_ETRPOLARITY_INVERTED
#define TIM_ENCODERINDEX_POLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED
#define TIM_CLOCKPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED
#define TIM_CLOCKPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED
#define TIM_CLEARINPUTPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED
#define TIM_CLEARINPUTPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED
#define TIM_TRIGGERPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED
#define TIM_TRIGGERPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED
Note
In HAL1, all the parameters that configure the polarity of external signals are redefined to
|
typedef enum
{
HAL_TIM_EXT_TRIG_NONINVERTED,
HAL_TIM_EXT_TRIG_INVERTED
} hal_tim_ext_trig_polarity_t;
Note In HAL2, the configuration for selecting the TIM external trigger polarity is enhanced, allowing developers to specify the desired polarity directly. |
HAL TIM polarity TI selection constants ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_TRIGGERPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING
#define TIM_TRIGGERPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING
#define TIM_TRIGGERPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE
#define TIM_CLOCKPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING
#define TIM_CLOCKPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING
#define TIM_CLOCKPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE
#define TIM_ENCODERINPUTPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING
#define TIM_ENCODERINPUTPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING
#define TIM_ICPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING
#define TIM_ICPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING
#define TIM_ICPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE
Note
In HAL1, all the parameters that configure the polarity of timer input are redefined to
|
typedef enum
{
HAL_TIM_IC_RISING,
HAL_TIM_IC_FALLING,
HAL_TIM_IC_RISING_FALLING
} hal_tim_ic_polarity_t;
Note In HAL2, the configuration for selecting the TIM input channel polarity is enhanced, allowing developers to specify the desired polarity directly. |
HAL TIM prescaler selection constants ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_TRIGGERPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1
#define TIM_TRIGGERPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2
#define TIM_TRIGGERPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4
#define TIM_TRIGGERPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8
#define TIM_CLEARINPUTPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1
#define TIM_CLEARINPUTPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2
#define TIM_CLEARINPUTPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4
#define TIM_CLEARINPUTPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8
#define TIM_CLOCKPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1
#define TIM_CLOCKPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2
#define TIM_CLOCKPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4
#define TIM_CLOCKPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8
#define TIM_ENCODERINDEX_PRESCALER_DIV1 TIM_ETRPRESCALER_DIV1
#define TIM_ENCODERINDEX_PRESCALER_DIV2 TIM_ETRPRESCALER_DIV2
#define TIM_ENCODERINDEX_PRESCALER_DIV4 TIM_ETRPRESCALER_DIV4
#define TIM_ENCODERINDEX_PRESCALER_DIV8 TIM_ETRPRESCALER_DIV8
Note
In HAL1, all the parameters that configure the prescaler of of external signals are redefined to
|
typedef enum
{
HAL_TIM_EXT_TRIG_DIV1,
HAL_TIM_EXT_TRIG_DIV2,
HAL_TIM_EXT_TRIG_DIV4,
HAL_TIM_EXT_TRIG_DIV8
} hal_tim_ext_trig_prescaler_t;
Note In HAL2, the configuration for selecting the TIM external trigger prescaler is enhanced, allowing developers to specify the desired prescaler directly. |
HAL TIM trigger source ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_TS_ITR0
#define TIM_TS_ITR1
#define TIM_TS_ITR2
.
.
.
#define TIM_TS_ETRF
#define TIM_TS_NONE
|
typedef enum
{
HAL_TIM_TRIG_ITR0,
HAL_TIM_TRIG_ITR1,
HAL_TIM_TRIG_ITR2,
.
.
.
HAL_TIM_TRIG_ETRF
} hal_tim_trig_sel_t;
|
Note
TIM_TS_NONE
is removed in HAL2 since the use case that existed in HAL1 will not be available.
For further
explanation
HAL TIM output state ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_OUTPUTSTATE_ENABLE
|
Removed
and use LL constants
|
#define TIM_OUTPUTSTATE_DISABLE
|
Removed
and use LL constants
|
Note
TIM_OUTPUTNSTATE_DISABLE
and
TIM_OUTPUTNSTATE_ENABLE
have also been removed.
To configure the output state, use
LL_TIM_OCSTATE_ENABLE
or
LL_TIM_OCSTATE_DISABLE
and specify the corresponding complementary channel..
HAL TIM interrupt flag ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_IT_CC1
|
Removed
; use LL constant
|
#define TIM_IT_CC2
|
Removed
; use LL constant
|
#define TIM_IT_CC3
|
Removed
; use LL constant
|
#define TIM_IT_CC4
|
Removed
; use LL constant
|
HAL TIM DMA source ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_DMA_UPDATE
|
Removed
; use LL constant
|
#define TIM_DMA_CC1
|
Removed
; use LL constant
|
#define TIM_DMA_CC2
|
Removed
; use LL constant
|
#define TIM_DMA_CC3
|
Removed
; use LL constant
|
#define TIM_DMA_CC4
|
Removed
; use LL constant
|
#define TIM_DMA_COM
|
Removed
; use LL constant
|
#define TIM_DMA_TRIGGER
|
Removed
; use LL constant
|
HAL TIM flag ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_FLAG_UPDATE
|
Removed
; use LL constant
|
#define TIM_FLAG_CC1
|
Removed
; use LL constant
|
#define TIM_FLAG_CC2
|
Removed
; use LL constant
|
#define TIM_FLAG_CC3
|
Removed
; use LL constant
|
#define TIM_FLAG_CC4
|
Removed
; use LL constant
|
#define TIM_FLAG_CC5
|
Removed
; use LL constant
|
#define TIM_FLAG_CC6
|
Removed
; use LL constant
|
#define TIM_FLAG_COM
|
Removed
; use LL constant
|
#define TIM_FLAG_TRIGGER
|
Removed
; use LL constant
|
#define TIM_FLAG_BREAK
|
Removed
; use LL constant
|
#define TIM_FLAG_BREAK2
|
Removed
; use LL constant
|
#define TIM_FLAG_SYSTEM_BREAK
|
Removed
; use LL constant
|
#define TIM_FLAG_CC1OF
|
Removed
; use LL constant
|
#define TIM_FLAG_CC2OF
|
Removed
; use LL constant
|
#define TIM_FLAG_CC3OF
|
Removed
; use LL constant
|
#define TIM_FLAG_CC4OF
|
Removed
; use LL constant
|
#define TIM_FLAG_IDX
|
Removed
; use LL constant
|
#define TIM_FLAG_DIR
|
Removed
; use LL constant
|
#define TIM_FLAG_IERR
|
Removed
; use LL constant
|
#define TIM_FLAG_TERR
|
Removed
; use LL constant
|
HAL TIM update interrupt flag ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_UIFREMAP_ENABLE
|
Removed
; use unitary function
|
#define TIM_UIFREMAP_DISABLE
|
Removed
; use unitary function
|
HAL TIM TI1 input selection ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_TI1SELECTION_XORCOMBINATION
|
Removed
; use unitary function
|
Note
In HAL2 there is no need for the
TIM_TI1SELECTION_CH1
macro, because it is the default timer setting.
If the
TIM_TI1SELECTION_XORCOMBINATION
is selected and you want to change it to
TIM_TI1SELECTION_CH1,
simply call the
HAL_TIM_IC_DisableXORGate()
function.
HAL TIM autoreload preload ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_AUTORELOAD_PRELOAD_DISABLE
|
Removed
; use unitary function
|
#define TIM_AUTORELOAD_PRELOAD_ENABLE
|
Removed
; use unitary function
|
HAL TIM fast mode ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_OCFAST_DISABLE
|
Removed
; use unitary function
|
#define TIM_OCFAST_ENABLE
|
Removed
; use unitary function
|
HAL TIM one pulse single mode ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_OPMODE_SINGLE
|
Removed
; use unitary function
|
Note
In HAL2, the
TIM_OPMODE_REPETITIVE
macro is no longer required, as the default timer configuration is repetitive.
If the timer is configured in one-pulse mode and must be switched to repetitive mode, the
HAL_TIM_DisableOnePulseMode()
function shall be called.
HAL TIM master slave mode ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_MASTERSLAVEMODE_ENABLE
|
Removed
; use unitary function
|
#define TIM_MASTERSLAVEMODE_DISABLE
|
Removed
; use unitary function
|
HAL TIM break input source ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_BREAKINPUTSOURCE_BKIN
#define TIM_BREAKINPUTSOURCE_COMP1
#define TIM_BREAKINPUTSOURCE_COMP2
.
.
.
|
#define HAL_TIM_BRK_TIM1_GPIO
#define HAL_TIM_BRK_TIM1_COMP1_OUT
#define HAL_TIM_BRK_TIM1_COMP2_OUT
.
.
.
Note In HAL2, break input sources are defined as macro constants, with the timer instance included in each macro name. As a result, these constants are now instance-specific and no longer shared across instances. |
HAL TIM break input source enable ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_BREAKINPUTSOURCE_DISABLE
|
Removed
; use unitary function
|
#define TIM_BREAKINPUTSOURCE_ENABLE
|
Removed
; use unitary function
|
HAL TIM break enable/disable ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_BREAK_ENABLE
#define TIM_BREAK2_ENABLE
|
Removed
; use unitary function
|
#define TIM_BREAK_DISABLE
#define TIM_BREAK2_DISABLE
|
Removed
; use unitary function
|
HAL TIM automatic output enable/disable ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_AUTOMATICOUTPUT_ENABLE
|
Removed
; use unitary function
|
#define TIM_AUTOMATICOUTPUT_DISABLE
|
Removed
; use unitary function
|
HAL TIM CCx enable/disable ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_CCx_ENABLE
#define TIM_CCxN_ENABLE
|
Removed
; use LL function
|
#define TIM_CCx_DISABLE
#define TIM_CCxN_DISABLE
|
Removed
; use LL function
|
HAL TIM channel all ¶
|
HAL1 |
HAL2 |
|---|---|
#define TIM_CHANNEL_ALL
|
Removed
; In HAL1, the
|